home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / exec / remtail.c < prev    next >
C/C++ Source or Header  |  1996-09-12  |  2KB  |  86 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: remtail.c,v 1.5 1996/08/13 13:56:07 digulla Exp $
  4.     $Log: remtail.c,v $
  5.     Revision 1.5  1996/08/13 13:56:07  digulla
  6.     Replaced __AROS_LA by __AROS_LHA
  7.     Replaced some __AROS_LH*I by __AROS_LH*
  8.     Sorted and added includes
  9.  
  10.     Revision 1.4  1996/08/01 17:41:17  digulla
  11.     Added standard header for all files
  12.  
  13.     Desc:
  14.     Lang: english
  15. */
  16. /* I want the macros */
  17. #define AROS_ALMOST_COMPATIBLE
  18. #include "exec_intern.h"
  19.  
  20. /*****************************************************************************
  21.  
  22.     NAME */
  23.     #include <exec/lists.h>
  24.     #include <clib/exec_protos.h>
  25.  
  26.     __AROS_LH1I(struct Node *, RemTail,
  27.  
  28. /*  SYNOPSIS */
  29.     __AROS_LHA(struct List *, list, A0),
  30.  
  31. /*  LOCATION */
  32.     struct SysBase *, SysBase, 44, Exec)
  33.  
  34. /*  FUNCTION
  35.     Remove the last node from a list.
  36.  
  37.     INPUTS
  38.     list - Remove the node from this list
  39.  
  40.     RESULT
  41.     The node that has been removed.
  42.  
  43.     NOTES
  44.  
  45.     EXAMPLE
  46.     struct List * list;
  47.     struct Node * tail;
  48.  
  49.     // Remove node and return it
  50.     tail = RemTail (list);
  51.  
  52.     BUGS
  53.  
  54.     SEE ALSO
  55.  
  56.     INTERNALS
  57.  
  58.     HISTORY
  59.     26-08-95    digulla created after EXEC-Routine
  60.     26-10-95    digulla adjusted to new calling scheme
  61.  
  62. ******************************************************************************/
  63. {
  64.     __AROS_FUNC_INIT
  65.     struct Node * node;
  66.  
  67.     assert (list);
  68.     /*
  69.     Unfortunately, there is no (quick) check that the node
  70.     is in a list.
  71.     */
  72.  
  73.     /* Get the last node of the list */
  74.     if ( (node = GetTail (list)) )
  75.     {
  76.     /* normal code to remove a node if there is one */
  77.     node->ln_Pred->ln_Succ = node->ln_Succ;
  78.     node->ln_Succ->ln_Pred = node->ln_Pred;
  79.     }
  80.  
  81.     /* return it's address or NULL if there was no node */
  82.     return node;
  83.     __AROS_FUNC_EXIT
  84. } /* RemTail */
  85.  
  86.